﻿using System;
using System.Collections.Generic;
using System.IO;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YArchitech.Revit;
using YArchitech.Revit.RevitExtension;
using HYDragCurveJig;
using HYElectricKernel;
using HYElectricSystemDiagram.DataStruct;
using HYRElectric.PowerSystem;

namespace HYElectricSystemDiagram.TMethod
{
	public class SystemDiagramDrawingKit
	{
        public SystemDiagramDrawingKit(string apName, XYZ point, ExternalCommandData cmdData, int viewScale, Autodesk.Revit.DB.Color switchLegendColor, GraphicsStyle frameStyle, GraphicsStyle midLineStyle, GraphicsStyle thickStyle, GraphicsStyle fineStyle, GraphicsStyle tableThickStyle, GraphicsStyle tableFineStyle, TextNoteType textNoteType, Element elem, List<int> lstint, string _MachName, string _MachNameE, UserControlData1 _UserControl)
		{
			this.AppName = apName;
			this.m_Revit = cmdData;
			this.m_ViewScale = viewScale;
			this.m_SwitchLegendColor = switchLegendColor;
			this.m_Doc = this.m_Revit.Application.ActiveUIDocument.Document;
			this.m_frameStyle = frameStyle;
			this.m_midLineStyle = midLineStyle;
			this.m_thickStyle = thickStyle;
			this.m_fineStyle = fineStyle;
			this.m_tableThickStyle = tableThickStyle;
			this.m_tableFineStyle = tableFineStyle;
			this.m_TextNoteType = textNoteType;
			this.BasePoint = point;
			this.nCount = lstint.Count;
			if (this.nCount <= 1)
			{
				this.nCount = 2;
			}
			this.lstFanElementID = lstint;
			this.strMachName = _MachName;
			if (this.strMachName.Contains("双速"))
			{
				this.DoubleSwich = true;
			}
			this.strMachNameE = _MachNameE;
			this.E_EleMach = elem;
			Plane plane = RevitVersionFuncs.CreatePlanByNormalAndOrigin(new XYZ(1.0, 1.0, 0.0), this.BasePoint);
			this.transform = RevitVersionFuncs.CreateReflection(plane);
			this.UserControl = _UserControl;
			this.StrTypeName = this.UserControl.strType;
			this.TidyUptheDataIn(this.UserControl);
		}

		private void TidyUptheDataIn(UserControlData1 userData)
		{
			double num = 0.0;
			WiringInstructions wiringInstructions = new WiringInstructions();
			foreach (WiringInstructions wiringInstructions2 in userData.m_WiringInstructions)
			{
				if (this.strMachName.Contains(wiringInstructions2.strTypeName))
				{
					wiringInstructions = wiringInstructions2;
					break;
				}
			}
			double num2 = 0.0;
			foreach (int elementId in this.lstFanElementID)
			{
				string text = GetElectricInfo.GetElectricMachi(this.m_Doc, elementId, this.StrTypeName, wiringInstructions, this.strMachName)[1].Replace("kW", "");
				double num5;
				if (text.Contains("/"))
				{
					string[] array = text.Split(new char[]
					{
						'/'
					});
					double num3 = double.Parse(array[0]);
					double num4 = double.Parse(array[1]);
					if (num3 > num4)
					{
						num5 = num3;
					}
					else
					{
						num5 = num4;
					}
				}
				else
				{
					num5 = double.Parse(text);
				}
				num2 += num5;
			}
			num = num2;
			LineSettingIn lineSettingIn = new LineSettingIn();
			if (num == 0.0)
			{
				lineSettingIn = userData.m_LineSettingIn[0];
			}
			else
			{
				foreach (LineSettingIn lineSettingIn2 in userData.m_LineSettingIn)
				{
					if (this.lstFanElementID.Count == 1)
					{
						if (num == lineSettingIn2.dBoxPowerSingle)
						{
							lineSettingIn = lineSettingIn2;
							break;
						}
					}
					else if (num == lineSettingIn2.dBoxPowerMulti)
					{
						lineSettingIn = lineSettingIn2;
						break;
					}
				}
			}
			if (lineSettingIn.strBreaker == null && lineSettingIn.strDoubleSwich == null && lineSettingIn.strKGL == null)
			{
				foreach (LineSettingIn lineSettingIn3 in userData.m_LineSettingIn)
				{
					if (this.lstFanElementID.Count == 1)
					{
						if (num < lineSettingIn3.dBoxPowerSingle)
						{
							lineSettingIn = lineSettingIn3;
							break;
						}
					}
					else if (num < lineSettingIn3.dBoxPowerMulti)
					{
						lineSettingIn = lineSettingIn3;
						break;
					}
				}
			}
			if (lineSettingIn.strBreaker == null && lineSettingIn.strDoubleSwich == null && lineSettingIn.strKGL == null)
			{
				int count = userData.m_LineSettingIn.Count;
				lineSettingIn = userData.m_LineSettingIn[count - 1];
			}
			this.lstInTxt.Clear();
			string empty = string.Empty;
			this.strMachNameE = this.AppName;
			this.lstInTxt.Add(this.strMachNameE);
			double num6;
			if (this.lstFanElementID.Count == 1)
			{
				num6 = lineSettingIn.dBoxPowerSingle;
			}
			else
			{
				num6 = lineSettingIn.dBoxPowerMulti;
			}
			num6 = num2;
			if (!this.DoubleSwich)
			{
				this.lstInTxt.Add("Pn=" + num6 + "kW");
			}
			else
			{
				this.lstInTxt.Add("Pn=" + num6 + "kW");
			}
			this.lstInTxt.Add("Kx=" + userData.dKx);
			this.lstInTxt.Add("Cosφ=" + userData.dCos);
			this.lstInTxt.Add("Pc=" + num6 * userData.dKx + "kW");
			double value = num6 * userData.dKx / (0.65817930685 * userData.dCos);
			this.lstInTxt.Add("Ic=" + Math.Round(value, 2) + "A");
			this.lstInTxt.Add("箱体尺寸:" + userData.strBoxSize);
			string text2 = this.E_EleMach.GetParameter("安装高度").AsDouble().ToString();
			string text3 = this.E_EleMach.GetParameter("安装方式").AsString();
			if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3))
			{
				this.lstInTxt.Add(text3 + " , 底边距地" + text2 + "米");
			}
			else
			{
				if (string.IsNullOrEmpty(text2))
				{
					this.lstInTxt.Add(text3);
				}
				if (string.IsNullOrEmpty(text3))
				{
					this.lstInTxt.Add("底边距地" + text2 + "米");
				}
			}
			this.lstInTxt.Add("控制电路方案号:" + wiringInstructions.strCircuitScheme);
			this.lstInTxt.Add("备注:" + wiringInstructions.strRemarks);
			this.lstInTxt.Add(" " + wiringInstructions.strSurge);
			this.lstInInfo.Clear();
			if (userData.blBreaker)
			{
				this.lstInInfo.Add(lineSettingIn.strBreaker);
			}
			else
			{
				this.lstInInfo.Add(lineSettingIn.strKGL);
			}
			if (this.UserControl.blSwichTwo)
			{
				this.lstInInfo.Add(lineSettingIn.strDoubleSwich);
			}
			if (num == 0.0)
			{
				this.lstInInfo.Clear();
				this.lstInInfo.Add(" ");
				this.lstInInfo.Add(" ");
			}
		}

		private bool TidyUptheDataOut(Autodesk.Revit.DB.Document doc, UserControlData1 userData, int id, out LineSettingOut m_LineSettingOutKit, out WiringInstructions m_WiringInstructionsKit)
		{
			Element element = doc.GetElement(new ElementId(id));
			m_LineSettingOutKit = null;
			m_WiringInstructionsKit = null;
			foreach (WiringInstructions wiringInstructions in userData.m_WiringInstructions)
			{
				if (this.strMachName.Contains(wiringInstructions.strTypeName))
				{
					m_WiringInstructionsKit = wiringInstructions;
					break;
				}
			}
			double power = GetElectricInfo.GetPower(doc, element, this.DoubleSwich);
			if (power == 0.0)
			{
				m_LineSettingOutKit = null;
				return false;
			}
			foreach (LineSettingOut lineSettingOut in userData.m_LineSettingOut)
			{
				if (lineSettingOut.dPowerRating >= power / 1000.0)
				{
					m_LineSettingOutKit = lineSettingOut;
					break;
				}
			}
			if (m_LineSettingOutKit == null)
			{
				m_LineSettingOutKit = userData.m_LineSettingOut[userData.m_LineSettingOut.Count - 1];
			}
			return m_WiringInstructionsKit != null;
		}

		public bool DrawSystemDiagramH(SystemGraphSet systemGraphSet)
		{
			this.LoopSpace = 3600.0;
			if (this.DoubleSwich)
			{
				this.LoopSpace = 5100.0;
			}
			this.dMidOffset = this.offset * 11.0;
			if (!this.UserControl.blSwichTwo)
			{
				this.dMidOffset = this.offset * 7.0;
			}
			this.blHorizontal = true;
			double num = 2500.0;
			this.m_GeneratrixLength = AssistFunc.mmToFeet(((double)(this.nCount - 1) * this.LoopSpace / 2.0 + num) * 2.0);
			if (this.lstFanElementID.Count == 1)
			{
				this.m_GeneratrixLength = AssistFunc.mmToFeet(11200.0);
			}
			if (this.lstFanElementID.Count == 2)
			{
				this.m_GeneratrixLength = AssistFunc.mmToFeet(10900.0);
			}
			XYZ vector = new XYZ(0.0, -this.m_GeneratrixLength * 0.5, 0.0);
			this.transformMove = RevitVersionFuncs.CreateTranslation(vector);
			this.m_TextNoteHeight = AssistFunc.mmToFeet(systemGraphSet.TextHeight);
			this.CreateSystemDiagramIN();
			this.CreateSystemDiagramINTxt();
			if (!this.DoubleSwich)
			{
				this.CreateSystemDiagramOut();
			}
			else
			{
				this.CreateSystemDiagramOutDouble();
			}
			this.CreateDashFrame();
			this.CreateSurgeH(this.lstInTxt[this.lstInTxt.Count - 1]);
			this.MoveTransform(this.blHorizontal);
			this.DrawModelSystemDiagram();
			return true;
		}

		public bool DrawSystemDiagramS(SystemGraphSet systemGraphSet)
		{
			this.LoopSpace = 5400.0;
			if (this.DoubleSwich)
			{
				this.LoopSpace = 9400.0;
			}
			this.dMidOffset = this.offset * 9.0;
			if (!this.UserControl.blSwichTwo)
			{
				this.dMidOffset = this.offset * 5.0;
			}
			this.blHorizontal = false;
			double num = 2500.0;
			this.m_GeneratrixLength = AssistFunc.mmToFeet(((double)(this.nCount - 1) * this.LoopSpace / 2.0 + num) * 2.0);
			if (this.lstFanElementID.Count == 1)
			{
				this.m_GeneratrixLength = AssistFunc.mmToFeet(11200.0);
			}
			if (this.lstFanElementID.Count == 2)
			{
				this.m_GeneratrixLength = AssistFunc.mmToFeet(10900.0);
			}
			XYZ vector = new XYZ(this.m_GeneratrixLength * 0.5, 0.0, 0.0);
			this.transformMove = RevitVersionFuncs.CreateTranslation(vector);
			this.m_TextNoteHeight = AssistFunc.mmToFeet(systemGraphSet.TextHeight);
			this.CreateSystemDiagramINS();
			if (!this.DoubleSwich)
			{
				this.CreateSystemDiagramOutS();
			}
			else
			{
				this.CreateSystemDiagramOutDoubleS();
			}
			this.MirrorTransformN(this.blHorizontal);
			this.MoveTransform(this.blHorizontal);
			this.CreateSurgeS(this.lstInTxt[this.lstInTxt.Count - 1]);
			this.CreateTable();
			XYZ centerPoint = this.CreateTableContentIN();
			this.CreateTableContentOut(centerPoint);
			this.DrawModelSystemDiagram();
			return true;
		}

		private bool CreateSystemDiagramIN()
		{
			XYZ basePoint = this.BasePoint;
			List<XYZ> list = new List<XYZ>();
			if (this.UserControl.blSwichTwo)
			{
				XYZ xyz = new XYZ(basePoint.X - this.offset, basePoint.Y + this.offset * 2.0, basePoint.Z);
				XYZ xyz2 = new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + this.offset * 2.0, basePoint.Z);
				XYZ xyz3 = new XYZ(basePoint.X - this.offset, basePoint.Y - this.offset * 2.0, basePoint.Z);
				XYZ xyz4 = new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y - this.offset * 2.0, basePoint.Z);
				this.lstCurve.Add(Line.CreateBound(xyz, xyz2));
				this.lstCurve.Add(Line.CreateBound(xyz3, xyz4));
				this.lstInPoint.Add(xyz2);
				this.lstInPoint.Add(xyz4);
				this.lstInPoint.Add(new XYZ(xyz2.X + this.offset * 3.0, basePoint.Y, basePoint.Z));
				list.Add(new XYZ(xyz2.X + this.offset, xyz2.Y + this.offset, xyz2.Z));
				list.Add(new XYZ(xyz4.X + this.offset * 5.0, basePoint.Y + this.offset * 4.0, xyz4.Z));
			}
			else
			{
				XYZ xyz5 = new XYZ(basePoint.X - this.offset, basePoint.Y, basePoint.Z);
				XYZ xyz6 = new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y, basePoint.Z);
				this.lstCurve.Add(Line.CreateBound(xyz5, xyz6));
				this.lstCurve.Add(Line.CreateBound(xyz5, xyz6));
				list.Add(new XYZ(xyz6.X + this.offset, xyz6.Y + this.offset, xyz6.Z));
				this.lstInPoint.Add(xyz6);
			}
			XYZ xyz7 = new XYZ(basePoint.X + this.dMidOffset - this.offset * 2.0, basePoint.Y, basePoint.Z);
			XYZ xyz8 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y, basePoint.Z);
			this.lstCurve.Add(Line.CreateBound(xyz7, xyz8));
			int num = 0;
			foreach (string text in this.lstInInfo)
			{
				if (!string.IsNullOrEmpty(text))
				{
					double textWidth = this.GetTextWidth(text);
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list[num], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, textWidth, text));
					num++;
				}
			}
			double num2 = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 700.0);
			if (this.DoubleSwich)
			{
				num2 = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 1450.0);
			}
			XYZ xyz9 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y + num2, basePoint.Z);
			XYZ xyz10 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y - num2, basePoint.Z);
			if (!this.UserControl.blSurge)
			{
				this.lstMidCurve.Add(Line.CreateBound(xyz9, xyz10));
			}
			else
			{
				xyz10 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y - num2 - this.offset * 2.0, basePoint.Z);
				this.lstMidCurve.Add(Line.CreateBound(xyz9, xyz10));
			}
			return true;
		}

		private bool CreateSystemDiagramINS()
		{
			XYZ basePoint = this.BasePoint;
			new List<XYZ>();
			if (this.UserControl.blSwichTwo)
			{
				XYZ xyz = new XYZ(basePoint.X, basePoint.Y + this.offset * 2.0, basePoint.Z);
				XYZ xyz2 = new XYZ(basePoint.X + this.offset, basePoint.Y + this.offset * 2.0, basePoint.Z);
				XYZ xyz3 = new XYZ(basePoint.X, basePoint.Y - this.offset * 2.0, basePoint.Z);
				XYZ xyz4 = new XYZ(basePoint.X + this.offset, basePoint.Y - this.offset * 2.0, basePoint.Z);
				this.lstCurve.Add(Line.CreateBound(xyz, xyz2));
				this.lstCurve.Add(Line.CreateBound(xyz3, xyz4));
				this.lstInPoint.Add(xyz2);
				this.lstInPoint.Add(xyz4);
				this.lstInPoint.Add(new XYZ(xyz2.X + this.offset * 3.0, basePoint.Y, basePoint.Z));
			}
			else
			{
				XYZ xyz5 = new XYZ(basePoint.X, basePoint.Y, basePoint.Z);
				XYZ xyz6 = new XYZ(basePoint.X + this.offset, basePoint.Y, basePoint.Z);
				this.lstCurve.Add(Line.CreateBound(xyz5, xyz6));
				this.lstCurve.Add(Line.CreateBound(xyz5, xyz6));
				this.lstInPoint.Add(xyz6);
			}
			XYZ xyz7 = new XYZ(basePoint.X + this.dMidOffset - this.offset, basePoint.Y, basePoint.Z);
			XYZ xyz8 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y, basePoint.Z);
			this.lstCurve.Add(Line.CreateBound(xyz7, xyz8));
			double num = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 1000.0);
			if (this.DoubleSwich)
			{
				num = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 3000.0);
			}
			XYZ xyz9 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y + num, basePoint.Z);
			XYZ xyz10 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y - num, basePoint.Z);
			this.lstMidCurve.Add(Line.CreateBound(xyz9, xyz10));
			return true;
		}

		private bool CreateSystemDiagramINTxt()
		{
			XYZ basePoint = this.BasePoint;
			List<XYZ> list = new List<XYZ>();
			double num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0 + 2500.0);
			double num2 = AssistFunc.mmToFeet(720.0);
			if (this.lstFanElementID.Count < 3)
			{
				num = AssistFunc.mmToFeet(5600.0);
			}
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + num - this.offset / 2.0, basePoint.Z));
			string appName = this.AppName;
			this.lstCurveTxt.Add(Line.CreateBound(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + num - num2, basePoint.Z), new XYZ(basePoint.X + this.offset * 2.0 + (double)appName.Length * 0.49212598425196846, basePoint.Y + num - num2, basePoint.Z)));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + num - this.offset * 2.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + num - this.offset * 3.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + num - this.offset * 4.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + num - this.offset * 5.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y + num - this.offset * 6.0, basePoint.Z));
			if (this.lstFanElementID.Count == 1)
			{
				num = AssistFunc.mmToFeet(3500.0);
			}
			if (this.lstFanElementID.Count == 2)
			{
				num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0 + 2500.0);
			}
			if (this.lstFanElementID.Count != 1 && this.UserControl.blSurge)
			{
				num = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0 + 2500.0);
			}
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y - num + this.offset * 3.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y - num + this.offset * 2.0, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y - num + this.offset, basePoint.Z));
			list.Add(new XYZ(basePoint.X + this.offset * 2.0, basePoint.Y - num - this.offset, basePoint.Z));
			int num3 = 0;
			foreach (string text in this.lstInTxt)
			{
				double textWidth = this.GetTextWidth(text);
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list[num3], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth, text));
				num3++;
				if (num3 == this.lstInTxt.Count - 1)
				{
					break;
				}
			}
			return true;
		}

		private void CreateDashFrame()
		{
			double num;
			if (this.UserControl.blSwichTwo)
			{
				num = this.offset * 28.0;
				if (!this.UserControl.blBreakerOut)
				{
					num = this.offset * 18.0;
				}
			}
			else
			{
				num = this.offset * 24.0;
				if (!this.UserControl.blBreakerOut)
				{
					num = this.offset * 14.0;
				}
			}
			XYZ basePoint = this.BasePoint;
			double num2 = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0 + 2500.0);
			if (this.lstFanElementID.Count < 3)
			{
				num2 = AssistFunc.mmToFeet(5600.0);
			}
			XYZ xyz = new XYZ(basePoint.X, basePoint.Y + num2, basePoint.Z);
			XYZ xyz2 = new XYZ(basePoint.X + num, basePoint.Y + num2, basePoint.Z);
			XYZ xyz3 = new XYZ(basePoint.X, basePoint.Y - num2, basePoint.Z);
			XYZ xyz4 = new XYZ(basePoint.X + num, basePoint.Y - num2, basePoint.Z);
			if (this.UserControl.blSurge)
			{
				if (this.lstFanElementID.Count == 1)
				{
					num2 = AssistFunc.mmToFeet(2500.0);
				}
				else
				{
					num2 = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0 + 1500.0);
				}
				xyz3 = new XYZ(basePoint.X, basePoint.Y - num2 - this.offset * 2.0, basePoint.Z);
				xyz4 = new XYZ(basePoint.X + num, basePoint.Y - num2 - this.offset * 2.0, basePoint.Z);
			}
			else
			{
				if (this.lstFanElementID.Count == 1)
				{
					num2 = AssistFunc.mmToFeet(3500.0);
				}
				if (this.lstFanElementID.Count == 2)
				{
					num2 = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0 + 2500.0);
				}
				xyz3 = new XYZ(basePoint.X, basePoint.Y - num2, basePoint.Z);
				xyz4 = new XYZ(basePoint.X + num, basePoint.Y - num2, basePoint.Z);
			}
			this.lstDashCurve.Add(Line.CreateBound(xyz, xyz2));
			this.lstDashCurve.Add(Line.CreateBound(xyz2, xyz4));
			this.lstDashCurve.Add(Line.CreateBound(xyz4, xyz3));
			this.lstDashCurve.Add(Line.CreateBound(xyz3, xyz));
		}

		private bool CreateSystemDiagramOut()
		{
			int num = 0;
			XYZ basePoint = this.BasePoint;
			double num2 = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0);
			if (this.lstFanElementID.Count == 1)
			{
				num2 = 0.0;
			}
			double num3 = AssistFunc.mmToFeet(this.LoopSpace);
			double num4 = AssistFunc.mmToFeet(400.0);
			XYZ xyz = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y + num2, basePoint.Z);
			XYZ xyz2 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 2.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz3 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 5.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz4 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz5 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 10.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz6 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 12.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz7 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 15.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz8 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 31.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz9 = new XYZ(xyz8.X + num4, xyz8.Y, xyz8.Z);
			XYZ xyz10 = xyz2;
			XYZ xyz11 = xyz4;
			XYZ xyz12 = xyz6;
			XYZ xyz13 = new XYZ(0.0, 0.0, 0.0);
			if (!this.UserControl.blBreakerOut)
			{
				xyz4 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 21.0, basePoint.Y + num2, basePoint.Z);
				xyz9 = new XYZ(xyz4.X + num4, xyz4.Y, xyz4.Z);
				xyz13 = xyz2;
			}
			XYZ xyz14 = new XYZ(xyz9.X + num4 * 2.0, xyz9.Y + num4 / 2.0 + this.offset / 2.0 + this.offset / 5.0, basePoint.Z);
			XYZ xyz15 = new XYZ(xyz9.X + num4 * 2.0, xyz9.Y - num4 / 2.0 + this.offset / 2.0 - this.offset / 5.0, basePoint.Z);
			XYZ xyz16 = new XYZ(xyz9.X + num4 + this.offset / 5.0, xyz9.Y, basePoint.Z);
			XYZ xyz17 = new XYZ(xyz9.X + num4 * 5.0 + this.offset / 5.0, xyz9.Y, basePoint.Z);
			num4 = AssistFunc.mmToFeet(300.0);
			XYZ xyz18 = new XYZ(xyz10.X - this.offset, xyz10.Y + this.offset, xyz10.Z);
			XYZ xyz19 = new XYZ(xyz11.X, xyz11.Y + this.offset, xyz11.Z);
			XYZ xyz20 = new XYZ(xyz12.X, xyz12.Y + this.offset * 2.0, xyz12.Z);
			XYZ xyz21 = new XYZ(xyz13.X, xyz13.Y + this.offset, xyz13.Z);
			XYZ xyz22 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 18.0, xyz.Y + this.offset, basePoint.Z);
			XYZ xyz23 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 20.0, xyz.Y + this.offset, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz22 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 8.0, xyz.Y + this.offset, basePoint.Z);
				xyz23 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 10.0, xyz.Y + this.offset, basePoint.Z);
			}
			XYZ xyz24 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 + this.offset / 2.0, xyz.Y - num4 + this.offset / 2.0, basePoint.Z);
			XYZ xyz25 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 + this.offset / 2.0, xyz.Y - num4 * 3.0 + this.offset / 2.0, basePoint.Z);
			XYZ xyz26 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 + this.offset / 2.0, xyz.Y - num4 * 5.0 + this.offset / 2.0, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz24 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 + this.offset / 2.0, xyz.Y - num4 + this.offset / 2.0, basePoint.Z);
				xyz25 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 + this.offset / 2.0, xyz.Y - num4 * 3.0 + this.offset / 2.0, basePoint.Z);
				xyz26 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 + this.offset / 2.0, xyz.Y - num4 * 5.0 + this.offset / 2.0, basePoint.Z);
			}
			double num5 = AssistFunc.mmToFeet(600.0);
			XYZ xyz27 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 - num5, basePoint.Y + num2 - num5, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz27 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 - num5, basePoint.Y + num2 - num5, basePoint.Z);
			}
			XYZ xyz28 = new XYZ(xyz27.X + 20.341207349081365, xyz27.Y, xyz27.Z);
			foreach (int num6 in this.lstFanElementID)
			{
				XYZ xyz29 = new XYZ(xyz.X, xyz.Y - num3 * (double)num, xyz.Z);
				XYZ xyz30 = new XYZ(xyz2.X, xyz2.Y - num3 * (double)num, xyz2.Z);
				XYZ xyz31 = new XYZ(xyz3.X, xyz3.Y - num3 * (double)num, xyz3.Z);
				XYZ xyz32 = new XYZ(xyz4.X, xyz4.Y - num3 * (double)num, xyz4.Z);
				XYZ xyz33 = new XYZ(xyz5.X, xyz5.Y - num3 * (double)num, xyz5.Z);
				XYZ xyz34 = new XYZ(xyz6.X, xyz6.Y - num3 * (double)num, xyz6.Z);
				XYZ xyz35 = new XYZ(xyz7.X, xyz7.Y - num3 * (double)num, xyz7.Z);
				XYZ xyz36 = new XYZ(xyz8.X, xyz8.Y - num3 * (double)num, xyz8.Z);
				XYZ xyz37 = new XYZ(xyz27.X, xyz27.Y - num3 * (double)num, xyz27.Z);
				XYZ xyz38 = new XYZ(xyz28.X, xyz28.Y - num3 * (double)num, xyz28.Z);
				XYZ xyz39 = new XYZ(xyz27.X, xyz27.Y - num3 * (double)num - num5 * 1.0, xyz27.Z);
				XYZ xyz40 = new XYZ(xyz28.X, xyz28.Y - num3 * (double)num - num5 * 1.0, xyz28.Z);
				XYZ xyz41 = new XYZ(xyz27.X, xyz27.Y - num3 * (double)num - num5 * 2.0, xyz27.Z);
				XYZ xyz42 = new XYZ(xyz28.X, xyz28.Y - num3 * (double)num - num5 * 2.0, xyz28.Z);
				this.lstCurve.Add(Line.CreateBound(xyz29, xyz30));
				this.lstCurve.Add(Line.CreateBound(xyz31, xyz32));
				if (this.UserControl.blBreakerOut)
				{
					this.lstCurve.Add(Line.CreateBound(xyz33, xyz34));
					this.lstCurve.Add(Line.CreateBound(xyz35, xyz36));
				}
				LineSettingOut lineSettingOut = null;
				WiringInstructions wiringInstructions = null;
				if (this.TidyUptheDataOut(this.m_Doc, this.UserControl, num6, out lineSettingOut, out wiringInstructions))
				{
					if (wiringInstructions.lstWiringInstructions.Count > 0)
					{
						this.lstCurveTxt.Add(Line.CreateBound(xyz37, xyz38));
					}
					if (wiringInstructions.lstWiringInstructions.Count > 1 && wiringInstructions.lstWiringInstructions[1].Trim() != "")
					{
						this.lstCurveTxt.Add(Line.CreateBound(xyz39, xyz40));
					}
					if (wiringInstructions.lstWiringInstructions.Count > 2 && wiringInstructions.lstWiringInstructions[2].Trim() != "")
					{
						this.lstCurveTxt.Add(Line.CreateBound(xyz41, xyz42));
					}
				}
				List<XYZ> list = new List<XYZ>();
				list.Add(new XYZ(xyz10.X, xyz10.Y - num3 * (double)num, xyz10.Z));
				list.Add(new XYZ(xyz11.X, xyz11.Y - num3 * (double)num, xyz11.Z));
				list.Add(new XYZ(xyz12.X, xyz12.Y - num3 * (double)num, xyz12.Z));
				if (!this.UserControl.blBreakerOut)
				{
					list.Clear();
					list.Add(new XYZ(xyz13.X, xyz13.Y - num3 * (double)num, xyz13.Z));
				}
				list.Add(new XYZ(xyz9.X, xyz9.Y - num3 * (double)num, xyz9.Z));
				this.lstlstOutPoint.Add(list);
				List<XYZ> list2 = new List<XYZ>();
				list2.Add(new XYZ(xyz18.X, xyz18.Y - num3 * (double)num, xyz18.Z));
				list2.Add(new XYZ(xyz19.X, xyz19.Y - num3 * (double)num, xyz19.Z));
				list2.Add(new XYZ(xyz20.X, xyz20.Y - num3 * (double)num, xyz20.Z));
				if (!this.UserControl.blBreakerOut)
				{
					list2.Clear();
					list2.Add(new XYZ(xyz21.X, xyz21.Y - num3 * (double)num, xyz21.Z));
					list2.Add(new XYZ(xyz21.X, xyz21.Y - num3 * (double)num, xyz21.Z));
					list2.Add(new XYZ(xyz21.X, xyz21.Y - num3 * (double)num, xyz21.Z));
				}
				list2.Add(new XYZ(xyz22.X, xyz22.Y - num3 * (double)num, xyz22.Z));
				list2.Add(new XYZ(xyz23.X, xyz23.Y - num3 * (double)num, xyz23.Z));
				list2.Add(new XYZ(xyz24.X, xyz24.Y - num3 * (double)num, xyz24.Z));
				list2.Add(new XYZ(xyz25.X, xyz25.Y - num3 * (double)num, xyz25.Z));
				list2.Add(new XYZ(xyz26.X, xyz26.Y - num3 * (double)num, xyz26.Z));
				this.lstlstOutTxt.Add(list2);
				List<string> electricMachi = GetElectricInfo.GetElectricMachi(this.m_Doc, num6, this.StrTypeName, wiringInstructions, this.strMachName);
				double textWidth = this.GetTextWidth(electricMachi[0]);
				XYZ origin = new XYZ(xyz14.X, xyz14.Y - num3 * (double)num, xyz14.Z);
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth, electricMachi[0]));
				textWidth = this.GetTextWidth(electricMachi[1]);
				XYZ origin2 = new XYZ(xyz15.X, xyz15.Y - num3 * (double)num, xyz15.Z);
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth, electricMachi[1]));
				XYZ xyz43 = new XYZ(xyz16.X, xyz16.Y - num3 * (double)num, xyz16.Z);
				XYZ xyz44 = new XYZ(xyz17.X, xyz17.Y - num3 * (double)num, xyz17.Z);
				this.lstCurveTxt.Add(Line.CreateBound(xyz43, xyz44));
				num++;
			}
			int num7 = 1;
			foreach (List<XYZ> list3 in this.lstlstOutTxt)
			{
				LineSettingOut lineSettingOut2 = null;
				WiringInstructions wiringInstructions2 = null;
				bool flag = this.TidyUptheDataOut(this.m_Doc, this.UserControl, this.lstFanElementID[num7 - 1], out lineSettingOut2, out wiringInstructions2);
				if (lineSettingOut2 == null)
				{
					num7++;
				}
				else
				{
					string text = lineSettingOut2.strBreaker;
					if (!this.UserControl.blBreakerOut)
					{
						text = lineSettingOut2.strCps;
					}
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[0], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(text), text));
					if (this.UserControl.blBreakerOut)
					{
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[1], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOut2.strContactor), lineSettingOut2.strContactor));
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[2], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOut2.strHotRelay), lineSettingOut2.strHotRelay));
					}
					string text2 = "WPE" + num7;
					if (this.UserControl.strType.Equals("普通风机") || this.UserControl.strType.Equals("普通潜污泵"))
					{
						text2 = "WP" + num7;
					}
					double textWidth2 = this.GetTextWidth(text2);
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[3], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth2, text2));
					string text3 = string.Concat(new object[]
					{
						this.UserControl.strLineType,
						"-",
						lineSettingOut2.strOutLine,
						"  ",
						this.UserControl.strSpoolType,
						lineSettingOut2.dPipeDiameter,
						"-",
						lineSettingOut2.strPerfunctoryWay
					});
					textWidth2 = this.GetTextWidth(text3);
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[4], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth2, text3));
					if (flag)
					{
						if (wiringInstructions2.lstWiringInstructions.Count > 0)
						{
							this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[5], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions2.lstWiringInstructions[0]), wiringInstructions2.lstWiringInstructions[0]));
						}
						if (wiringInstructions2.lstWiringInstructions.Count > 1)
						{
							this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[6], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions2.lstWiringInstructions[1]), wiringInstructions2.lstWiringInstructions[1]));
						}
						if (wiringInstructions2.lstWiringInstructions.Count > 2)
						{
							this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[7], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions2.lstWiringInstructions[2]), wiringInstructions2.lstWiringInstructions[2]));
						}
					}
					num7++;
				}
			}
			return true;
		}

		private bool CreateSystemDiagramOutS()
		{
			int num = 0;
			XYZ basePoint = this.BasePoint;
			double num2 = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0);
			if (this.lstFanElementID.Count == 1)
			{
				num2 = 0.0;
			}
			double num3 = AssistFunc.mmToFeet(this.LoopSpace);
			double num4 = AssistFunc.mmToFeet(400.0);
			XYZ xyz = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y + num2, basePoint.Z);
			XYZ xyz2 = new XYZ(basePoint.X + this.dMidOffset + this.offset, basePoint.Y + num2, basePoint.Z);
			XYZ xyz3 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 10.0, basePoint.Y + num2, basePoint.Z);
			XYZ xyz4 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 11.0, basePoint.Y + num2, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz3 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 4.0, basePoint.Y + num2, basePoint.Z);
				xyz4 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0, basePoint.Y + num2, basePoint.Z);
			}
			XYZ xyz5 = new XYZ(xyz4.X + num4, xyz4.Y, xyz4.Z);
			XYZ xyz6 = xyz2;
			XYZ xyz7 = xyz2 + XYZ.BasisX * this.offset * 3.0;
			XYZ xyz8 = xyz2 + XYZ.BasisX * this.offset * 6.0;
			XYZ xyz9 = new XYZ(0.0, 0.0, 0.0);
			if (!this.UserControl.blBreakerOut)
			{
				xyz9 = xyz2;
			}
			num4 = AssistFunc.mmToFeet(300.0);
			new XYZ(xyz6.X, xyz6.Y + this.offset, xyz6.Z);
			new XYZ(xyz7.X, xyz7.Y + this.offset, xyz7.Z);
			new XYZ(xyz8.X, xyz8.Y + this.offset * 2.0, xyz8.Z);
			new XYZ(xyz9.X, xyz9.Y + this.offset, xyz9.Z);
			foreach (int num5 in this.lstFanElementID)
			{
				XYZ xyz10 = new XYZ(xyz.X, xyz.Y - num3 * (double)num, xyz.Z);
				XYZ xyz11 = new XYZ(xyz2.X, xyz2.Y - num3 * (double)num, xyz2.Z);
				XYZ xyz12 = new XYZ(xyz3.X, xyz3.Y - num3 * (double)num, xyz3.Z);
				XYZ xyz13 = new XYZ(xyz4.X, xyz4.Y - num3 * (double)num, xyz4.Z);
				this.lstCurve.Add(Line.CreateBound(xyz10, xyz11));
				this.lstCurve.Add(Line.CreateBound(xyz12, xyz13));
				if (this.UserControl.blBreakerOut)
				{
					this.lstCurve.Add(Line.CreateBound(xyz12, xyz13));
				}
				List<XYZ> list = new List<XYZ>();
				list.Add(new XYZ(xyz6.X, xyz6.Y - num3 * (double)num, xyz6.Z));
				list.Add(new XYZ(xyz7.X, xyz7.Y - num3 * (double)num, xyz7.Z));
				list.Add(new XYZ(xyz8.X, xyz8.Y - num3 * (double)num, xyz8.Z));
				if (!this.UserControl.blBreakerOut)
				{
					list.Clear();
					list.Add(new XYZ(xyz9.X, xyz9.Y - num3 * (double)num, xyz9.Z));
				}
				list.Add(new XYZ(xyz5.X, xyz5.Y - num3 * (double)num, xyz5.Z));
				this.lstlstOutPoint.Add(list);
				num++;
			}
			return true;
		}

		private bool CreateSystemDiagramOutDouble()
		{
			double num = AssistFunc.mmToFeet(750.0);
			if (!this.blHorizontal)
			{
				num = AssistFunc.mmToFeet(2000.0);
			}
			XYZ xyz = XYZ.BasisY * num;
			int num2 = 0;
			XYZ basePoint = this.BasePoint;
			double num3 = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0);
			if (this.lstFanElementID.Count == 1)
			{
				num3 = 0.0;
			}
			double num4 = AssistFunc.mmToFeet(this.LoopSpace);
			double num5 = AssistFunc.mmToFeet(400.0);
			XYZ xyz2 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y + num3, basePoint.Z);
			XYZ xyz3 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 2.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz4 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 5.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz5 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz6 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 10.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz7 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 12.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz8 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 15.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz9 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 31.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz10 = new XYZ(xyz9.X + num5, xyz9.Y, xyz9.Z);
			XYZ xyz11 = xyz3;
			XYZ xyz12 = xyz5;
			XYZ xyz13 = xyz7;
			XYZ xyz14 = new XYZ(0.0, 0.0, 0.0);
			if (!this.UserControl.blBreakerOut)
			{
				xyz5 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 21.0, basePoint.Y + num3, basePoint.Z);
				xyz10 = new XYZ(xyz5.X + num5, xyz5.Y, xyz5.Z);
				xyz14 = xyz3;
			}
			XYZ xyz15 = new XYZ(xyz10.X + num5 * 2.0, xyz10.Y + num5 + this.offset / 2.0, basePoint.Z);
			XYZ xyz16 = new XYZ(xyz10.X + num5 * 2.0, xyz10.Y - num5, basePoint.Z);
			XYZ xyz17 = new XYZ(xyz10.X + num5 + this.offset / 5.0, xyz10.Y, basePoint.Z);
			XYZ xyz18 = new XYZ(xyz10.X + num5 * 5.0 + this.offset / 5.0, xyz10.Y, basePoint.Z);
			num5 = AssistFunc.mmToFeet(300.0);
			XYZ xyz19 = new XYZ(xyz11.X - this.offset, xyz11.Y + this.offset, xyz11.Z);
			XYZ xyz20 = new XYZ(xyz12.X, xyz12.Y + this.offset, xyz12.Z);
			XYZ xyz21 = new XYZ(xyz13.X, xyz13.Y + this.offset * 2.0, xyz13.Z);
			XYZ xyz22 = new XYZ(xyz14.X, xyz14.Y + this.offset, xyz14.Z);
			XYZ xyz23 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 18.0, xyz2.Y + this.offset, basePoint.Z);
			XYZ xyz24 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 20.0, xyz2.Y + this.offset, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz23 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 8.0, xyz2.Y + this.offset, basePoint.Z);
				xyz24 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 10.0, xyz2.Y + this.offset, basePoint.Z);
			}
			XYZ xyz25 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 + this.offset / 2.0, xyz2.Y - num5 + this.offset / 2.0, basePoint.Z);
			XYZ xyz26 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 + this.offset / 2.0, xyz2.Y - num5 * 3.0 + this.offset / 2.0, basePoint.Z);
			XYZ xyz27 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 + this.offset / 2.0, xyz2.Y - num5 * 5.0 + this.offset / 2.0, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz25 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 + this.offset / 2.0, xyz2.Y - num5 + this.offset / 2.0, basePoint.Z);
				xyz26 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 + this.offset / 2.0, xyz2.Y - num5 * 3.0 + this.offset / 2.0, basePoint.Z);
				xyz27 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 + this.offset / 2.0, xyz2.Y - num5 * 5.0 + this.offset / 2.0, basePoint.Z);
			}
			double num6 = AssistFunc.mmToFeet(600.0);
			XYZ xyz28 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 17.0 - num6, basePoint.Y + num3 - num6, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz28 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0 - num6, basePoint.Y + num3 - num6, basePoint.Z);
			}
			XYZ xyz29 = new XYZ(xyz28.X + 20.341207349081365, xyz28.Y, xyz28.Z);
			foreach (int num7 in this.lstFanElementID)
			{
				XYZ xyz30 = new XYZ(xyz2.X, xyz2.Y - num4 * (double)num2, xyz2.Z);
				XYZ xyz31 = new XYZ(xyz3.X, xyz3.Y - num4 * (double)num2, xyz3.Z);
				XYZ xyz32 = new XYZ(xyz4.X, xyz4.Y - num4 * (double)num2, xyz4.Z);
				XYZ xyz33 = new XYZ(xyz5.X, xyz5.Y - num4 * (double)num2, xyz5.Z);
				XYZ xyz34 = new XYZ(xyz6.X, xyz6.Y - num4 * (double)num2, xyz6.Z);
				XYZ xyz35 = new XYZ(xyz7.X, xyz7.Y - num4 * (double)num2, xyz7.Z);
				XYZ xyz36 = new XYZ(xyz8.X, xyz8.Y - num4 * (double)num2, xyz8.Z);
				XYZ xyz37 = new XYZ(xyz9.X, xyz9.Y - num4 * (double)num2, xyz9.Z);
				XYZ xyz38 = new XYZ(xyz28.X, xyz28.Y - num4 * (double)num2, xyz28.Z);
				XYZ xyz39 = new XYZ(xyz29.X, xyz29.Y - num4 * (double)num2, xyz29.Z);
				XYZ xyz40 = new XYZ(xyz28.X, xyz28.Y - num4 * (double)num2 - num6 * 1.0, xyz28.Z);
				XYZ xyz41 = new XYZ(xyz29.X, xyz29.Y - num4 * (double)num2 - num6 * 1.0, xyz29.Z);
				XYZ xyz42 = new XYZ(xyz28.X, xyz28.Y - num4 * (double)num2 - num6 * 2.0, xyz28.Z);
				XYZ xyz43 = new XYZ(xyz29.X, xyz29.Y - num4 * (double)num2 - num6 * 2.0, xyz29.Z);
				this.lstCurve.Add(Line.CreateBound(xyz30 + xyz, xyz31 + xyz));
				this.lstCurve.Add(Line.CreateBound(xyz30 - xyz, xyz31 - xyz));
				this.lstCurve.Add(Line.CreateBound(xyz32 + xyz, xyz33 + xyz));
				this.lstCurve.Add(Line.CreateBound(xyz32 - xyz, xyz33 - xyz));
				double num8 = AssistFunc.mmToFeet(400.0);
				if (this.UserControl.blBreakerOut)
				{
					this.lstCurve.Add(Line.CreateBound(xyz34 + xyz, xyz35 + xyz));
					this.lstCurve.Add(Line.CreateBound(xyz34 - xyz, xyz35 - xyz));
					this.lstCurve.Add(Line.CreateBound(xyz36 + xyz, xyz37 + xyz));
					this.lstCurve.Add(Line.CreateBound(xyz36 - xyz, xyz37 - xyz));
					XYZ xyz44 = xyz10 - XYZ.BasisY * num4 * (double)num2 + num8 * (xyz37 + xyz - (xyz10 - XYZ.BasisY * num4 * (double)num2)).Normalize();
					XYZ xyz45 = xyz10 - XYZ.BasisY * num4 * (double)num2 + num8 * (xyz37 - xyz - (xyz10 - XYZ.BasisY * num4 * (double)num2)).Normalize();
					this.lstCurve.Add(Line.CreateBound(xyz37 + xyz, xyz44));
					this.lstCurve.Add(Line.CreateBound(xyz37 - xyz, xyz45));
				}
				else
				{
					XYZ xyz46 = xyz10 - XYZ.BasisY * num4 * (double)num2 + num8 * (xyz33 + xyz - (xyz10 - XYZ.BasisY * num4 * (double)num2)).Normalize();
					XYZ xyz47 = xyz10 - XYZ.BasisY * num4 * (double)num2 + num8 * (xyz33 - xyz - (xyz10 - XYZ.BasisY * num4 * (double)num2)).Normalize();
					this.lstCurve.Add(Line.CreateBound(xyz33 + xyz, xyz46));
					this.lstCurve.Add(Line.CreateBound(xyz33 - xyz, xyz47));
				}
				LineSettingOut lineSettingOut = null;
				WiringInstructions wiringInstructions = null;
				if (this.TidyUptheDataOut(this.m_Doc, this.UserControl, num7, out lineSettingOut, out wiringInstructions))
				{
					if (wiringInstructions.lstWiringInstructions.Count > 0)
					{
						this.lstCurveTxt.Add(Line.CreateBound(xyz38 - xyz, xyz39 - xyz));
					}
					if (wiringInstructions.lstWiringInstructions.Count > 1 && wiringInstructions.lstWiringInstructions[1].Trim() != "")
					{
						this.lstCurveTxt.Add(Line.CreateBound(xyz40 - xyz, xyz41 - xyz));
					}
					if (wiringInstructions.lstWiringInstructions.Count > 2 && wiringInstructions.lstWiringInstructions[2].Trim() != "")
					{
						this.lstCurveTxt.Add(Line.CreateBound(xyz42 - xyz, xyz43 - xyz));
					}
				}
				List<XYZ> list = new List<XYZ>();
				list.Add(new XYZ(xyz11.X, xyz11.Y - num4 * (double)num2 + num, xyz11.Z));
				list.Add(new XYZ(xyz12.X, xyz12.Y - num4 * (double)num2 + num, xyz12.Z));
				list.Add(new XYZ(xyz13.X, xyz13.Y - num4 * (double)num2 + num, xyz13.Z));
				list.Add(new XYZ(xyz11.X, xyz11.Y - num4 * (double)num2 - num, xyz11.Z));
				list.Add(new XYZ(xyz12.X, xyz12.Y - num4 * (double)num2 - num, xyz12.Z));
				list.Add(new XYZ(xyz13.X, xyz13.Y - num4 * (double)num2 - num, xyz13.Z));
				if (!this.UserControl.blBreakerOut)
				{
					list.Clear();
					list.Add(new XYZ(xyz14.X, xyz14.Y - num4 * (double)num2 + num, xyz14.Z));
					list.Add(new XYZ(xyz14.X, xyz14.Y - num4 * (double)num2 - num, xyz14.Z));
				}
				list.Add(new XYZ(xyz10.X, xyz10.Y - num4 * (double)num2, xyz10.Z));
				this.lstlstOutPoint.Add(list);
				List<XYZ> list2 = new List<XYZ>();
				list2.Add(new XYZ(xyz19.X, xyz19.Y - num4 * (double)num2 + num, xyz19.Z));
				list2.Add(new XYZ(xyz19.X, xyz19.Y - num4 * (double)num2 - num, xyz19.Z));
				list2.Add(new XYZ(xyz20.X, xyz20.Y - num4 * (double)num2 + num, xyz20.Z));
				list2.Add(new XYZ(xyz20.X, xyz20.Y - num4 * (double)num2 - num, xyz20.Z));
				list2.Add(new XYZ(xyz21.X, xyz21.Y - num4 * (double)num2 + num, xyz21.Z));
				list2.Add(new XYZ(xyz21.X, xyz21.Y - num4 * (double)num2 - num, xyz21.Z));
				if (!this.UserControl.blBreakerOut)
				{
					list2.Clear();
					list2.Add(new XYZ(xyz22.X, xyz22.Y - num4 * (double)num2 + num, xyz22.Z));
					list2.Add(new XYZ(xyz22.X, xyz22.Y - num4 * (double)num2 - num, xyz22.Z));
					list2.Add(new XYZ(xyz22.X, xyz22.Y - num4 * (double)num2 + num, xyz22.Z));
					list2.Add(new XYZ(xyz22.X, xyz22.Y - num4 * (double)num2 - num, xyz22.Z));
					list2.Add(new XYZ(xyz22.X, xyz22.Y - num4 * (double)num2 + num, xyz22.Z));
					list2.Add(new XYZ(xyz22.X, xyz22.Y - num4 * (double)num2 - num, xyz22.Z));
				}
				list2.Add(new XYZ(xyz23.X, xyz23.Y - num4 * (double)num2 + num, xyz23.Z));
				list2.Add(new XYZ(xyz23.X, xyz23.Y - num4 * (double)num2 - num, xyz23.Z));
				list2.Add(new XYZ(xyz24.X, xyz24.Y - num4 * (double)num2 + num, xyz24.Z));
				list2.Add(new XYZ(xyz24.X, xyz24.Y - num4 * (double)num2 - num, xyz24.Z));
				list2.Add(new XYZ(xyz25.X, xyz25.Y - num4 * (double)num2 - num, xyz25.Z));
				list2.Add(new XYZ(xyz26.X, xyz26.Y - num4 * (double)num2 - num, xyz26.Z));
				list2.Add(new XYZ(xyz27.X, xyz27.Y - num4 * (double)num2 - num, xyz27.Z));
				this.lstlstOutTxt.Add(list2);
				List<string> electricMachi = GetElectricInfo.GetElectricMachi(this.m_Doc, num7, this.StrTypeName, wiringInstructions, this.strMachName);
				double textWidth = this.GetTextWidth(electricMachi[0]);
				XYZ origin = new XYZ(xyz15.X, xyz15.Y - num4 * (double)num2, xyz15.Z);
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth, electricMachi[0]));
				if (electricMachi[1].Equals("0kW"))
				{
					electricMachi[1] = "0/0kW";
				}
				textWidth = this.GetTextWidth(electricMachi[1]);
				XYZ origin2 = new XYZ(xyz16.X, xyz16.Y - num4 * (double)num2, xyz16.Z);
				this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth, electricMachi[1]));
				XYZ xyz48 = new XYZ(xyz17.X, xyz17.Y - num4 * (double)num2, xyz17.Z);
				XYZ xyz49 = new XYZ(xyz18.X, xyz18.Y - num4 * (double)num2, xyz18.Z);
				this.lstCurveTxt.Add(Line.CreateBound(xyz48, xyz49));
				num2++;
			}
			int num9 = 1;
			foreach (List<XYZ> list3 in this.lstlstOutTxt)
			{
				LineSettingOut lineSettingOut2 = null;
				WiringInstructions wiringInstructions2 = null;
				bool flag = this.TidyUptheDataOut(this.m_Doc, this.UserControl, this.lstFanElementID[num9 - 1], out lineSettingOut2, out wiringInstructions2);
				if (lineSettingOut2 == null)
				{
					num9++;
				}
				else
				{
					string text = lineSettingOut2.strBreaker;
					if (!this.UserControl.blBreakerOut)
					{
						text = lineSettingOut2.strCps;
					}
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[0], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(text), text));
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[1], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(text), text));
					if (this.UserControl.blBreakerOut)
					{
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[2], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOut2.strContactor), lineSettingOut2.strContactor));
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[3], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOut2.strContactor), lineSettingOut2.strContactor));
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[4], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOut2.strHotRelay), lineSettingOut2.strHotRelay));
						this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[5], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(lineSettingOut2.strHotRelay), lineSettingOut2.strHotRelay));
					}
					string text2 = "WPE" + num9;
					if (this.UserControl.strType.Equals("普通风机") || this.UserControl.strType.Equals("普通潜污泵"))
					{
						text2 = "WP" + num9;
					}
					double textWidth2 = this.GetTextWidth(text2);
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[6], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth2, text2));
					string text3 = this.UserControl.strLineType + "-" + lineSettingOut2.strOutLine;
					textWidth2 = this.GetTextWidth(text3);
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[8], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth2, text3));
					this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[9], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, textWidth2, text3));
					if (flag)
					{
						if (wiringInstructions2.lstWiringInstructions.Count > 0)
						{
							this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[10], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions2.lstWiringInstructions[0]), wiringInstructions2.lstWiringInstructions[0]));
						}
						if (wiringInstructions2.lstWiringInstructions.Count > 1)
						{
							this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[11], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions2.lstWiringInstructions[1]), wiringInstructions2.lstWiringInstructions[1]));
						}
						if (wiringInstructions2.lstWiringInstructions.Count > 2)
						{
							this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, list3[12], XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions2.lstWiringInstructions[2]), wiringInstructions2.lstWiringInstructions[2]));
						}
					}
					num9++;
				}
			}
			return true;
		}

		private bool CreateSystemDiagramOutDoubleS()
		{
			double num = AssistFunc.mmToFeet(750.0);
			if (!this.blHorizontal)
			{
				num = AssistFunc.mmToFeet(2000.0);
			}
			XYZ xyz = XYZ.BasisY * num;
			int num2 = 0;
			XYZ basePoint = this.BasePoint;
			double num3 = AssistFunc.mmToFeet((double)(this.nCount - 1) * this.LoopSpace / 2.0);
			if (this.lstFanElementID.Count == 1)
			{
				num3 = 0.0;
			}
			double num4 = AssistFunc.mmToFeet(this.LoopSpace);
			double num5 = AssistFunc.mmToFeet(400.0);
			XYZ xyz2 = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y + num3, basePoint.Z);
			XYZ xyz3 = new XYZ(basePoint.X + this.dMidOffset + this.offset, basePoint.Y + num3, basePoint.Z);
			XYZ xyz4 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 10.0, basePoint.Y + num3, basePoint.Z);
			XYZ xyz5 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 11.0, basePoint.Y + num3, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz4 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 4.0, basePoint.Y + num3, basePoint.Z);
				xyz5 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 7.0, basePoint.Y + num3, basePoint.Z);
			}
			XYZ xyz6 = new XYZ(xyz5.X + num5, xyz5.Y, xyz5.Z);
			XYZ xyz7 = xyz3;
			XYZ xyz8 = xyz3 + XYZ.BasisX * this.offset * 3.0;
			XYZ xyz9 = xyz3 + XYZ.BasisX * this.offset * 6.0;
			XYZ xyz10 = new XYZ(0.0, 0.0, 0.0);
			if (!this.UserControl.blBreakerOut)
			{
				xyz10 = xyz3;
			}
			foreach (int num6 in this.lstFanElementID)
			{
				XYZ xyz11 = new XYZ(xyz2.X, xyz2.Y - num4 * (double)num2, xyz2.Z);
				XYZ xyz12 = new XYZ(xyz3.X, xyz3.Y - num4 * (double)num2, xyz3.Z);
				XYZ xyz13 = new XYZ(xyz4.X, xyz4.Y - num4 * (double)num2, xyz4.Z);
				XYZ xyz14 = new XYZ(xyz5.X, xyz5.Y - num4 * (double)num2, xyz5.Z);
				this.lstCurve.Add(Line.CreateBound(xyz11 + xyz, xyz12 + xyz));
				this.lstCurve.Add(Line.CreateBound(xyz11 - xyz, xyz12 - xyz));
				this.lstCurve.Add(Line.CreateBound(xyz13 + xyz, xyz14 + xyz));
				this.lstCurve.Add(Line.CreateBound(xyz13 - xyz, xyz14 - xyz));
				XYZ xyz15 = xyz6 - XYZ.BasisY * num4 * (double)num2 + num5 * (xyz14 + xyz - (xyz6 - XYZ.BasisY * num4 * (double)num2)).Normalize();
				XYZ xyz16 = xyz6 - XYZ.BasisY * num4 * (double)num2 + num5 * (xyz14 - xyz - (xyz6 - XYZ.BasisY * num4 * (double)num2)).Normalize();
				this.lstCurve.Add(Line.CreateBound(xyz14 + xyz, xyz15));
				this.lstCurve.Add(Line.CreateBound(xyz14 - xyz, xyz16));
				List<XYZ> list = new List<XYZ>();
				list.Add(new XYZ(xyz7.X, xyz7.Y - num4 * (double)num2 + num, xyz7.Z));
				list.Add(new XYZ(xyz8.X, xyz8.Y - num4 * (double)num2 + num, xyz8.Z));
				list.Add(new XYZ(xyz9.X, xyz9.Y - num4 * (double)num2 + num, xyz9.Z));
				list.Add(new XYZ(xyz7.X, xyz7.Y - num4 * (double)num2 - num, xyz7.Z));
				list.Add(new XYZ(xyz8.X, xyz8.Y - num4 * (double)num2 - num, xyz8.Z));
				list.Add(new XYZ(xyz9.X, xyz9.Y - num4 * (double)num2 - num, xyz9.Z));
				if (!this.UserControl.blBreakerOut)
				{
					list.Clear();
					list.Add(new XYZ(xyz10.X, xyz10.Y - num4 * (double)num2 + num, xyz10.Z));
					list.Add(new XYZ(xyz10.X, xyz10.Y - num4 * (double)num2 - num, xyz10.Z));
				}
				list.Add(new XYZ(xyz6.X, xyz6.Y - num4 * (double)num2, xyz6.Z));
				this.lstlstOutPoint.Add(list);
				num2++;
			}
			return true;
		}

		private bool CreateSurgeH(string info)
		{
			if (!this.UserControl.blSurge)
			{
				return false;
			}
			XYZ basePoint = this.BasePoint;
			double num = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 700.0);
			if (this.DoubleSwich)
			{
				num = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 1450.0);
			}
			XYZ xyz = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y - num - 0.98425196850393692, basePoint.Z);
			XYZ xyz2 = new XYZ(basePoint.X + this.dMidOffset + this.offset * 2.0, basePoint.Y - num - 0.98425196850393692, basePoint.Z);
			this.lstCurve.Add(Line.CreateBound(xyz, xyz2));
			this.lstSurgePoint.Add(xyz2);
			XYZ origin = new XYZ(basePoint.X + this.dMidOffset + this.offset * 4.0, basePoint.Y - num + this.offset / 2.0, basePoint.Z);
			double textWidth = this.GetTextWidth(info);
			this.m_OtherTextInfos.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, textWidth, info));
			return true;
		}

		private bool CreateSurgeS(string info)
		{
			if (!this.UserControl.blSurge)
			{
				return false;
			}
			XYZ basePoint = this.BasePoint;
			double num = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 1000.0);
			if (this.DoubleSwich)
			{
				num = AssistFunc.mmToFeet((double)(this.lstFanElementID.Count - 1) * this.LoopSpace / 2.0 + 3000.0);
			}
			XYZ xyz = new XYZ(basePoint.X + this.dMidOffset, basePoint.Y - num + this.offset, basePoint.Z);
			xyz = JigGeometry.TransformPoint(xyz, this.transform);
			xyz = JigGeometry.TransformPoint(xyz, this.transformMove);
			XYZ xyz2 = new XYZ(xyz.X, xyz.Y + this.offset / 5.0 * 4.0, xyz.Z);
			XYZ xyz3 = new XYZ(xyz2.X + this.offset * 2.0, xyz2.Y, xyz2.Z);
			this.lstCurve.Add(Line.CreateBound(xyz, xyz2));
			this.lstCurve.Add(Line.CreateBound(xyz2, xyz3));
			this.lstSurgePoint.Add(xyz3);
			XYZ origin = new XYZ(xyz3.X + this.offset * 2.0, xyz3.Y + this.offset, xyz3.Z);
			double textWidth = this.GetTextWidth(info);
			this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, textWidth, info));
			return true;
		}

		private bool CreateTable()
		{
			XYZ basePoint = this.BasePoint;
			XYZ xyz = new XYZ(basePoint.X + this.dMidOffset + this.offset * 14.0 - 2.2965879265091864, basePoint.Y, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz = new XYZ(basePoint.X + this.dMidOffset + this.offset * 9.0 - 0.65616797900262469, basePoint.Y, basePoint.Z);
			}
			xyz = JigGeometry.TransformPoint(xyz, this.transform);
			xyz = JigGeometry.TransformPoint(xyz, this.transformMove);
			double num = AssistFunc.mmToFeet(1300.0);
			XYZ xyz2 = new XYZ(xyz.X - num, xyz.Y - this.offset, xyz.Z);
			double num2 = 5400.0;
			if (this.DoubleSwich)
			{
				num2 = 8000.0;
			}
			double num3 = AssistFunc.mmToFeet(((double)this.lstFanElementID.Count * num2 + 2600.0) / 2.0);
			double num4 = AssistFunc.mmToFeet(800.0);
			double num5 = AssistFunc.mmToFeet(2600.0);
			List<string> tableNameType = TableName.GetTableNameType(this.UserControl.blSwichTwo, this.UserControl.blBreakerOut);
			int num6 = tableNameType.Count + 1;
			for (int i = 0; i < num6 - 2; i++)
			{
				XYZ xyz3 = new XYZ(xyz2.X - num3, xyz2.Y - num4 * (double)i, xyz2.Z);
				XYZ xyz4 = new XYZ(xyz2.X + num3, xyz2.Y - num4 * (double)i, xyz2.Z);
				if (i == 0)
				{
					this.lstCurveTableThick.Add(Line.CreateBound(xyz3, xyz4));
				}
				else
				{
					this.lstCurveTable.Add(Line.CreateBound(xyz3, xyz4));
				}
			}
			XYZ xyz5 = new XYZ(xyz2.X - num3, xyz2.Y - num4 * (double)(num6 - 1), xyz2.Z);
			XYZ xyz6 = new XYZ(xyz2.X + num3, xyz2.Y - num4 * (double)(num6 - 1), xyz2.Z);
			this.lstCurveTable.Add(Line.CreateBound(xyz5, xyz6));
			XYZ xyz7 = new XYZ(xyz2.X - num3, xyz2.Y - num4 * (double)num6, xyz2.Z);
			XYZ xyz8 = new XYZ(xyz2.X + num3, xyz2.Y - num4 * (double)num6, xyz2.Z);
			this.lstCurveTableThick.Add(Line.CreateBound(xyz7, xyz8));
			XYZ xyz9 = new XYZ(xyz2.X - num3, xyz2.Y, xyz2.Z);
			XYZ xyz10 = new XYZ(xyz2.X - num3, xyz2.Y - num4 * (double)num6, xyz2.Z);
			this.lstCurveTableThick.Add(Line.CreateBound(xyz9, xyz10));
			XYZ xyz11 = new XYZ(xyz2.X - num3 + num5, xyz2.Y, xyz2.Z);
			XYZ xyz12 = new XYZ(xyz2.X - num3 + num5, xyz2.Y - num4 * (double)num6, xyz2.Z);
			this.lstCurveTableThick.Add(Line.CreateBound(xyz11, xyz12));
			XYZ xyz13 = new XYZ(xyz2.X + num3, xyz2.Y, xyz2.Z);
			XYZ xyz14 = new XYZ(xyz2.X + num3, xyz2.Y - num4 * (double)num6, xyz2.Z);
			this.lstCurveTableThick.Add(Line.CreateBound(xyz13, xyz14));
			int num7 = 0;
			double num8 = AssistFunc.mmToFeet(1300.0);
			XYZ xyz15 = new XYZ(xyz9.X + num8, xyz9.Y - num4 / 3.0, xyz9.Z);
			foreach (string text in tableNameType)
			{
				XYZ origin = new XYZ(xyz15.X, xyz15.Y - num4 * (double)num7, xyz15.Z);
				double textWidth = this.GetTextWidth(text);
				this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, textWidth, text));
				num7++;
				if (num7 == tableNameType.Count - 2)
				{
					break;
				}
			}
			XYZ origin2 = new XYZ(xyz15.X, xyz15.Y - num4 * (double)(tableNameType.Count - 2) - num4 / 4.0, xyz15.Z);
			double textWidth2 = this.GetTextWidth(tableNameType[tableNameType.Count - 2]);
			this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, textWidth2, tableNameType[tableNameType.Count - 2]));
			origin2 = new XYZ(xyz15.X, xyz15.Y - num4 * (double)tableNameType.Count, xyz15.Z);
			textWidth2 = this.GetTextWidth(tableNameType[tableNameType.Count - 1]);
			this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, textWidth2, tableNameType[tableNameType.Count - 1]));
			return true;
		}

		private XYZ CreateTableContentIN()
		{
			XYZ result = this.BasePoint;
			XYZ basePoint = this.BasePoint;
			XYZ xyz = new XYZ(basePoint.X + this.dMidOffset + this.offset * 14.0 - 2.2965879265091864, basePoint.Y, basePoint.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz = new XYZ(basePoint.X + this.dMidOffset + this.offset * 9.0 - 0.65616797900262469, basePoint.Y, basePoint.Z);
			}
			xyz = JigGeometry.TransformPoint(xyz, this.transform);
			xyz = JigGeometry.TransformPoint(xyz, this.transformMove);
			double num = AssistFunc.mmToFeet(1300.0);
			XYZ xyz2 = new XYZ(xyz.X - num, xyz.Y - this.offset, xyz.Z);
			double num2 = 5400.0;
			if (this.DoubleSwich)
			{
				num2 = 8000.0;
			}
			double num3 = AssistFunc.mmToFeet(((double)this.lstFanElementID.Count * num2 + 2600.0) / 2.0);
			double num4 = AssistFunc.mmToFeet(800.0);
			XYZ xyz3 = new XYZ(xyz2.X - num3 + this.offset, xyz2.Y + this.dMidOffset + this.offset * 14.0, xyz2.Z);
			if (!this.UserControl.blBreakerOut)
			{
				xyz3 = new XYZ(xyz2.X - num3 + this.offset, xyz2.Y + this.dMidOffset + this.offset * 8.0 - num4, xyz2.Z);
			}
			for (int i = 1; i < 6; i++)
			{
				XYZ origin = new XYZ(xyz3.X, xyz3.Y - num4 / 2.0 * (double)(i - 1), xyz3.Z);
				this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(this.lstInTxt[i]), this.lstInTxt[i]));
			}
			XYZ xyz4 = xyz + XYZ.BasisY * -num4;
			this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz4, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, this.GetTextWidth(this.lstInTxt[0]), this.lstInTxt[0]));
			XYZ xyz5 = xyz4 + XYZ.BasisY * -num4;
			string[] array = this.lstInTxt[1].Split(new char[]
			{
				'='
			});
			this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz5, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, this.GetTextWidth(array[1]), array[1]));
			string text = this.lstInTxt[6].Split(new char[]
			{
				':'
			})[1] + "  " + this.lstInTxt[7];
			XYZ xyz6 = xyz5 + XYZ.BasisY * -num4;
			this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz6, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, this.GetTextWidth(text), text));
			XYZ xyz7 = xyz6 + XYZ.BasisY * -num4;
			this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz7, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, this.GetTextWidth(this.lstInInfo[0]), this.lstInInfo[0]));
			result = xyz + XYZ.BasisY * (-num4 * 4.0 - this.offset);
			if (this.UserControl.blSwichTwo)
			{
				XYZ origin2 = xyz7 + XYZ.BasisY * -num4;
				this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1024, this.GetTextWidth(this.lstInInfo[1]), this.lstInInfo[1]));
				result = xyz + XYZ.BasisY * (-num4 * 5.0 - this.offset);
			}
			return result;
		}

		private void CreateTableContentOut(XYZ centerPoint)
		{
			double num = 5400.0;
			if (this.DoubleSwich)
			{
				num = 8000.0;
			}
			double num2 = AssistFunc.mmToFeet((double)this.lstFanElementID.Count * num / 2.0);
			double num3 = AssistFunc.mmToFeet(800.0);
			XYZ xyz = new XYZ(centerPoint.X - num2, centerPoint.Y - num3 / 4.0, centerPoint.Z);
			num = AssistFunc.mmToFeet(num);
			for (int i = 0; i < this.lstFanElementID.Count; i++)
			{
				LineSettingOut lineSettingOut = null;
				WiringInstructions wiringInstructions = null;
				if (this.TidyUptheDataOut(this.m_Doc, this.UserControl, this.lstFanElementID[i], out lineSettingOut, out wiringInstructions))
				{
					string text = string.Concat(new object[]
					{
						this.UserControl.strSpoolType,
						lineSettingOut.dPipeDiameter,
						"-",
						lineSettingOut.strPerfunctoryWay
					});
					string text2 = this.UserControl.strLineType + "-" + lineSettingOut.strOutLine;
					string text3 = this.UserControl.strLineType + "-" + lineSettingOut.strOutLine;
					string text4 = lineSettingOut.strBreaker;
					if (!this.UserControl.blBreakerOut)
					{
						text4 = lineSettingOut.strCps;
					}
					XYZ xyz2 = xyz + XYZ.BasisX * (num / 2.0 + (double)i * num);
					string text5 = "WPE" + (i + 1).ToString();
					this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text5), text5));
					XYZ xyz4;
					if (!this.DoubleSwich)
					{
						XYZ xyz3 = xyz2 + XYZ.BasisY * -num3;
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz3, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text4), text4));
						xyz4 = xyz3;
						if (this.UserControl.blBreakerOut)
						{
							XYZ xyz5 = xyz4 + XYZ.BasisY * -num3;
							this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz5, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(lineSettingOut.strContactor), lineSettingOut.strContactor));
							XYZ xyz6 = xyz5 + XYZ.BasisY * -num3;
							this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz6, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(lineSettingOut.strHotRelay), lineSettingOut.strHotRelay));
							xyz4 = xyz6;
						}
						XYZ xyz7 = xyz4 + XYZ.BasisY * -num3;
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz7, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text3), text3));
						XYZ xyz8 = xyz7 + XYZ.BasisY * -num3;
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz8, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text), text));
						xyz4 = xyz8;
					}
					else
					{
						XYZ xyz9 = xyz2 + XYZ.BasisY * -num3;
						XYZ origin = xyz9 + XYZ.BasisX * (-num / 4.0);
						XYZ origin2 = xyz9 + XYZ.BasisX * (num / 4.0);
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text4), text4));
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin2, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text4), text4));
						xyz4 = xyz9;
						if (this.UserControl.blBreakerOut)
						{
							XYZ xyz10 = xyz4 + XYZ.BasisY * -num3;
							XYZ origin3 = xyz10 + XYZ.BasisX * (-num / 4.0);
							XYZ origin4 = xyz10 + XYZ.BasisX * (num / 4.0);
							this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin3, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(lineSettingOut.strContactor), lineSettingOut.strContactor));
							this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin4, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(lineSettingOut.strContactor), lineSettingOut.strContactor));
							XYZ xyz11 = xyz10 + XYZ.BasisY * -num3;
							XYZ origin5 = xyz11 + XYZ.BasisX * (-num / 4.0);
							XYZ origin6 = xyz11 + XYZ.BasisX * (num / 4.0);
							this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin5, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(lineSettingOut.strHotRelay), lineSettingOut.strHotRelay));
							this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin6, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(lineSettingOut.strHotRelay), lineSettingOut.strHotRelay));
							xyz4 = xyz11;
						}
						XYZ xyz12 = xyz4 + XYZ.BasisY * -num3;
						XYZ origin7 = xyz12 + XYZ.BasisX * (-num / 4.0);
						XYZ origin8 = xyz12 + XYZ.BasisX * (num / 4.0);
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin7, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text2), text2));
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin8, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text2), text2));
						XYZ xyz13 = xyz12 + XYZ.BasisY * -num3;
						XYZ origin9 = xyz13 + XYZ.BasisX * (-num / 4.0);
						XYZ origin10 = xyz13 + XYZ.BasisX * (num / 4.0);
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin9, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text), text));
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin10, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(text), text));
						xyz4 = xyz13;
					}
					List<string> electricMachi = GetElectricInfo.GetElectricMachi(this.m_Doc, this.lstFanElementID[i], this.StrTypeName, wiringInstructions, this.strMachName);
					XYZ xyz14 = xyz4 + XYZ.BasisY * -num3;
					this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz14, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(electricMachi[0]), electricMachi[0]));
					if (!this.DoubleSwich)
					{
						XYZ xyz15 = xyz14 + XYZ.BasisY * -num3;
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz15, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(electricMachi[1]), electricMachi[1]));
						xyz4 = xyz15;
					}
					else
					{
						if (!electricMachi[1].Contains("/"))
						{
							electricMachi[1] = "0/0kW";
						}
						string[] array = electricMachi[1].Split(new char[]
						{
							'/'
						});
						XYZ xyz16 = xyz14 + XYZ.BasisY * -num3;
						XYZ origin11 = xyz16 + XYZ.BasisX * (-num / 4.0);
						XYZ origin12 = xyz16 + XYZ.BasisX * (num / 4.0);
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin11, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(array[0] + "kW"), array[0] + "kW"));
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin12, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(array[1]), array[1]));
						xyz4 = xyz16;
					}
					if (i == 0)
					{
						XYZ xyz17 = xyz4 + XYZ.BasisY * -num3;
						string[] array2 = this.lstInTxt[8].Split(new char[]
						{
							':'
						});
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz17, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(array2[1]), array2[1]));
						XYZ origin13 = xyz17 + XYZ.BasisY * (-num3 * 3.0);
						string[] array3 = this.lstInTxt[9].Split(new char[]
						{
							':'
						});
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin13, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1152, this.GetTextWidth(array3[1]), array3[1]));
					}
					XYZ xyz18 = xyz4 + XYZ.BasisY * (-num3 - 2.1325459317585302);
					if (wiringInstructions.lstWiringInstructions.Count > 0)
					{
						xyz18 += XYZ.BasisX * (-num / 2.0 + this.offset / 50.0 * 3.0);
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz18, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions.lstWiringInstructions[0]), wiringInstructions.lstWiringInstructions[0]));
					}
					XYZ xyz19 = xyz18 + XYZ.BasisY * (-num3 * 2.0 / 3.0);
					if (wiringInstructions.lstWiringInstructions.Count > 1)
					{
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, xyz19, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions.lstWiringInstructions[1]), wiringInstructions.lstWiringInstructions[1]));
					}
					if (wiringInstructions.lstWiringInstructions.Count > 2)
					{
						XYZ origin14 = xyz19 + XYZ.BasisY * (-num3 * 2.0 / 3.0);
						this.m_TableTxt.Add(new JigTextInfo(this.m_TextNoteType, origin14, XYZ.BasisX, XYZ.BasisY, (Autodesk.Revit.DB.TextAlignFlags)1088, this.GetTextWidth(wiringInstructions.lstWiringInstructions[2]), wiringInstructions.lstWiringInstructions[2]));
					}
					if (this.lstFanElementID.Count > 1 && i > 0)
					{
						XYZ xyz20 = new XYZ(centerPoint.X - num2 + (double)i * num, centerPoint.Y, centerPoint.Z);
						XYZ xyz21 = new XYZ(xyz20.X, xyz20.Y - num3 * 6.0, xyz20.Z);
						if (this.UserControl.blBreakerOut)
						{
							xyz21 = new XYZ(xyz20.X, xyz20.Y - num3 * 8.0, xyz20.Z);
						}
						this.lstCurveTable.Add(Line.CreateBound(xyz20, xyz21));
						XYZ xyz22 = new XYZ(xyz21.X, xyz21.Y - num3, xyz21.Z);
						XYZ xyz23 = new XYZ(xyz22.X, xyz22.Y - num3 * 2.0, xyz22.Z);
						this.lstCurveTable.Add(Line.CreateBound(xyz22, xyz23));
					}
					if (this.DoubleSwich)
					{
						XYZ xyz24 = new XYZ(centerPoint.X - num2 + (double)i * num, centerPoint.Y, centerPoint.Z);
						XYZ xyz25 = new XYZ(xyz24.X + num / 2.0, xyz24.Y - num3, xyz24.Z);
						XYZ xyz26 = new XYZ(xyz25.X, xyz25.Y - num3 * 3.0, xyz25.Z);
						if (this.UserControl.blBreakerOut)
						{
							xyz26 = new XYZ(xyz25.X, xyz25.Y - num3 * 5.0, xyz25.Z);
						}
						this.lstCurveTable.Add(Line.CreateBound(xyz25, xyz26));
						XYZ xyz27 = new XYZ(xyz26.X, xyz26.Y - num3, xyz26.Z);
						XYZ xyz28 = new XYZ(xyz27.X, xyz27.Y - num3, xyz27.Z);
						this.lstCurveTable.Add(Line.CreateBound(xyz27, xyz28));
					}
				}
			}
		}

		private bool DrawModelSystemDiagram()
		{
			Transaction transaction = new Transaction(this.m_Doc, "tr");
			try
			{
				transaction.Start();
				foreach (Curve curve in this.lstCurve)
				{
					this.DrawCurve(curve, this.m_thickStyle);
				}
				foreach (Curve curve2 in this.lstCurveTableThick)
				{
					this.DrawCurve(curve2, this.m_tableThickStyle);
				}
				foreach (Curve curve3 in this.lstCurveTable)
				{
					this.DrawCurve(curve3, this.m_tableFineStyle);
				}
				if (this.blHorizontal)
				{
					foreach (JigTextInfo textInfo in this.m_OtherTextInfos)
					{
						this.DrawTextNote(textInfo);
					}
					using (List<Curve>.Enumerator enumerator = this.lstCurveTxt.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							Curve curve4 = enumerator.Current;
							this.DrawCurve(curve4, this.m_fineStyle);
						}
						goto IL_190;
					}
				}
				foreach (JigTextInfo textInfo2 in this.m_TableTxt)
				{
					this.DrawTextNote(textInfo2);
				}
				IL_190:
				foreach (Curve curve5 in this.lstMidCurve)
				{
					this.DrawCurve(curve5, this.m_midLineStyle);
				}
				List<ElementId> list = new List<ElementId>();
				foreach (Curve curve6 in this.lstDashCurve)
				{
					DetailCurve detailCurve = this.DrawCurve(curve6, this.m_frameStyle);
					list.Add(detailCurve.Id);
				}
				LinePatternElement linePatternElementByName = LinePatternElement.GetLinePatternElementByName(this.m_Doc, "划线");
				if (linePatternElementByName == null)
				{
					linePatternElementByName = LinePatternElement.GetLinePatternElementByName(this.m_Doc, "Dash");
				}
				if (linePatternElementByName != null)
				{
					this.m_Doc.ActiveView.SetYJKProjLinePatternOverrideByElement(list, linePatternElementByName);
				}
				transaction.Commit();
				Transaction transaction2 = new Transaction(this.m_Doc, "tr");
				transaction2.Start();
				this.CreateInFamily();
				this.CreateOutFamily(this.DoubleSwich);
				this.CreateSurgeFamily();
				transaction2.Commit();
			}
			catch
			{
				transaction.RollBack();
				return false;
			}
			return true;
		}

		private void CreateInFamily()
		{
			string familyName = "图例_隔离开关";
			if (this.UserControl.blBreaker)
			{
				familyName = "图例_断路器";
			}
			if (this.UserControl.blSwichTwo)
			{
				this.CreateFamily(familyName, this.lstInPoint[0], this.blHorizontal);
				this.CreateFamily(familyName, this.lstInPoint[1], this.blHorizontal);
				this.CreateFamily("图例_双电源转换开关", this.lstInPoint[2], this.blHorizontal);
				return;
			}
			this.CreateFamily(familyName, this.lstInPoint[0], this.blHorizontal);
		}

		private void CreateOutFamily(bool bl)
		{
			foreach (List<XYZ> list in this.lstlstOutPoint)
			{
				if (this.UserControl.blBreakerOut)
				{
					this.CreateFamily("图例_断路器", list[0], this.blHorizontal);
					this.CreateFamily("图例_接触器", list[1], this.blHorizontal);
					this.CreateFamily("图例_热继电器", list[2], this.blHorizontal);
					if (!bl)
					{
						this.CreateFamily("图例_电动机", list[3], this.blHorizontal);
					}
					else
					{
						this.CreateFamily("图例_断路器", list[3], this.blHorizontal);
						this.CreateFamily("图例_接触器", list[4], this.blHorizontal);
						this.CreateFamily("图例_热继电器", list[5], this.blHorizontal);
						this.CreateFamily("图例_电动机", list[6], this.blHorizontal);
					}
				}
				else
				{
					this.CreateFamily("图例_CPS", list[0], this.blHorizontal);
					if (!bl)
					{
						this.CreateFamily("图例_电动机", list[1], this.blHorizontal);
					}
					else
					{
						this.CreateFamily("图例_CPS", list[1], this.blHorizontal);
						this.CreateFamily("图例_电动机", list[2], this.blHorizontal);
					}
				}
			}
		}

		private void CreateSurgeFamily()
		{
			foreach (XYZ point in this.lstSurgePoint)
			{
				this.CreateFamily("图例_浪涌保护器", point, true);
			}
		}

		private FamilySymbol GetFamilySymbol(Autodesk.Revit.DB.Document doc, string FamilyName)
		{
			FamilySymbol familySymbol = YJKRevitTools.GetFamilySymbol(FamilyName, doc);
			if (familySymbol != null)
			{
				return familySymbol;
			}
			string path = "SystemDiagram\\" + FamilyName + ".rfa";
			string text = Path.Combine(Product.FamilyLocation, RevitVersion.Version, path);
			if (!File.Exists(text))
			{
				return familySymbol;
			}
			doc.LoadFamilySymbol(text, FamilyName, out familySymbol);
			if (familySymbol != null && !familySymbol.IsActive)
			{
				familySymbol.Activate();
			}
			return familySymbol;
		}

		private AnnotationSymbol CreateFamily(string familyName, XYZ point, bool bl)
		{
			XYZ xyz = XYZ.BasisX;
			if (!bl)
			{
				point = JigGeometry.TransformPoint(point, this.transform);
				xyz = XYZ.BasisY;
			}
			XYZ xyz2 = point;
			point = JigGeometry.TransformPoint(point, this.transformMove);
			if (!this.blHorizontal && familyName.Contains("浪涌"))
			{
				point = xyz2;
			}
			FamilySymbol familySymbol = this.GetFamilySymbol(this.m_Doc, familyName);
			AnnotationSymbol annotationSymbol = this.m_Doc.Create.NewFamilyInstance(point, familySymbol, this.m_Doc.ActiveView) as AnnotationSymbol;
			if (xyz.IsAlmostEqualTo(XYZ.BasisX))
			{
				return annotationSymbol;
			}
			Line line = YJKLineEx.YJKGetUnBound(point, XYZ.BasisZ);
			if (!familyName.Contains("电动机"))
			{
				ElementTransformUtils.RotateElement(this.m_Doc, annotationSymbol.Id, line, -Math.PI*.5);
			}
			return annotationSymbol;
		}

		private void MirrorTransformN(bool bl)
		{
			if (bl)
			{
				return;
			}
			List<Curve> list = new List<Curve>();
			foreach (Curve c in this.lstCurve)
			{
				Curve item = this.TransformSelf(c, this.transform);
				list.Add(item);
			}
			this.lstCurve.Clear();
			this.lstCurve = list;
			List<Curve> list2 = new List<Curve>();
			foreach (Curve c2 in this.lstMidCurve)
			{
				list2.Add(this.TransformSelf(c2, this.transform));
			}
			this.lstMidCurve.Clear();
			this.lstMidCurve = list2;
			List<Curve> list3 = new List<Curve>();
			foreach (Curve c3 in this.lstDashCurve)
			{
				list3.Add(this.TransformSelf(c3, this.transform));
			}
			this.lstDashCurve.Clear();
			this.lstDashCurve = list3;
		}

		private void MoveTransform(bool isHorizontal)
		{
			List<Curve> list = new List<Curve>();
			foreach (Curve c in this.lstCurve)
			{
				Curve item = this.TransformSelf(c, this.transformMove);
				list.Add(item);
			}
			this.lstCurve.Clear();
			this.lstCurve = list;
			List<Curve> list2 = new List<Curve>();
			foreach (Curve c2 in this.lstMidCurve)
			{
				list2.Add(this.TransformSelf(c2, this.transformMove));
			}
			this.lstMidCurve.Clear();
			this.lstMidCurve = list2;
			List<Curve> list3 = new List<Curve>();
			foreach (Curve c3 in this.lstDashCurve)
			{
				list3.Add(this.TransformSelf(c3, this.transformMove));
			}
			this.lstDashCurve.Clear();
			this.lstDashCurve = list3;
			for (int i = 0; i < this.m_BoxLineInfos.Count; i++)
			{
				this.m_BoxLineInfos[i].TransformSelf(this.transformMove);
			}
			for (int i = 0; i < this.m_OtherTextInfos.Count; i++)
			{
				this.m_OtherTextInfos[i].TransformSelf(this.transformMove, false);
			}
			List<Curve> list4 = new List<Curve>();
			foreach (Curve c4 in this.lstCurveTxt)
			{
				list4.Add(this.TransformSelf(c4, this.transformMove));
			}
			this.lstCurveTxt.Clear();
			this.lstCurveTxt = list4;
		}

		private Curve TransformSelf(Curve c, Transform matrix)
		{
			XYZ xyz = JigGeometry.TransformPoint(c.GetEndPoint(0), matrix);
			XYZ xyz2 = JigGeometry.TransformPoint(c.GetEndPoint(1), matrix);
			return Line.CreateBound(xyz, xyz2);
		}

		private DetailCurve DrawCurve(Curve curve, GraphicsStyle lineStyle)
		{
			DetailCurve result;
			try
			{
				Autodesk.Revit.DB.View activeView = this.m_Revit.Application.ActiveUIDocument.ActiveView;
				DetailCurve detailCurve = this.m_Revit.Application.ActiveUIDocument.Document.Create.NewDetailCurve(activeView, curve);
				if (detailCurve != null)
				{
					detailCurve.LineStyle = lineStyle;
				}
				result = detailCurve;
			}
			catch (Exception)
			{
				result = null;
			}
			return result;
		}

		private TextNote DrawTextNote(JigTextInfo textInfo)
		{
			if (textInfo.StrText.CompareTo("") == 0)
			{
				return null;
			}
			TextNote result;
			try
			{
				XYZ upVec = Geometry.RotateTo(textInfo.BaseVec, Math.PI*.5, XYZ.BasisZ);
				TextNote textNode = this.m_Doc.GetTextNode(this.m_Doc.ActiveView, textInfo.Origin, textInfo.BaseVec, upVec, textInfo.LineWidth, textInfo.TextAlign, textInfo.StrText);
				textNode.TextNoteType = textInfo.theTextNoteType;
				result = textNode;
			}
			catch (Exception)
			{
				result = null;
			}
			return result;
		}

		private double GetTextWidth(string str)
		{
			return (double)str.Length * this.m_TextNoteHeight * this.m_TextWHScale * 2.0;
		}

		private ExternalCommandData m_Revit;

		private Document m_Doc;

		private GraphicsStyle m_frameStyle;

		private GraphicsStyle m_midLineStyle;

		private GraphicsStyle m_thickStyle;

		private GraphicsStyle m_fineStyle;

		private GraphicsStyle m_tableThickStyle;

		private GraphicsStyle m_tableFineStyle;

		private TextNoteType m_TextNoteType;

		private List<JigEdgeInfo> m_CircuitLineInfos = new List<JigEdgeInfo>();

		private List<JigEdgeInfo> m_BoxLineInfos = new List<JigEdgeInfo>();

		private List<JigTextInfo> m_SystemInfoTextInfos = new List<JigTextInfo>();

		private List<JigTextInfo> m_OtherTextInfos = new List<JigTextInfo>();

		private double m_GeneratrixLength;

		private double m_TextNoteHeight;

		private double m_TextWHScale = 0.7;

		private int m_ViewScale;

        private Autodesk.Revit.DB.Color m_SwitchLegendColor;

		private List<Curve> lstCurve = new List<Curve>();

		private List<Curve> lstCurveTableThick = new List<Curve>();

		private List<Curve> lstCurveTable = new List<Curve>();

		private List<Curve> lstCurveTxt = new List<Curve>();

		private List<Curve> lstMidCurve = new List<Curve>();

		private List<Curve> lstDashCurve = new List<Curve>();

		private double offset = AssistFunc.mmToFeet(500.0);

		private List<XYZ> lstInPoint = new List<XYZ>();

		private List<List<XYZ>> lstlstOutPoint = new List<List<XYZ>>();

		private List<List<XYZ>> lstlstOutTxt = new List<List<XYZ>>();

		private XYZ ElectricMathchPoint = new XYZ();

		private XYZ BasePoint = new XYZ(0.0, 0.0, 0.0);

		private int nCount;

		private List<int> lstFanElementID = new List<int>();

		private List<FanPara> lstFan = new List<FanPara>();

		private string strMachName = "";

		private string strMachNameE = "";

		private bool DoubleSwich;

		private List<XYZ> lstSurgePoint = new List<XYZ>();

		private bool blHorizontal = true;

		private Transform transform;

		private Element E_EleMach;

		private List<JigTextInfo> m_TableTxt = new List<JigTextInfo>();

		private Transform transformMove;

		private double LoopSpace = 5400.0;

		private double dMidOffset;

		private UserControlData1 UserControl;

		private List<string> lstInTxt = new List<string>();

		private List<string> lstInInfo = new List<string>();

		private string StrTypeName = "";

		private string AppName = "";
	}
}
